const router = require('koa-router')();
const admin = require('./../model/admin');
router.post('/admin',async (ctx,next)=>{
    let userName=ctx.request.body.userName;
    let password=ctx.request.body.password;
    let doc=await admin.findOne({userName});

    if(doc){
        console.log(doc.userName)
        if(doc.password==password){
            ctx.body={
                status:1,
                msg:'登录成功',
                result:doc
            }
        }else{
            ctx.body={
                status:2,
                msg:'',
                result:'密码错误'
            }
        }
    }else{
        ctx.body={
            status:0,
            msg:'',
            result:'没有该账户'
        }
    }
})
module.exports = router;